using COC.Debug;
using UnityEngine;
using System.Collections;
using COC;
namespace COC.UIAction{
	public class LoginAction : BaseAction {
	  public UIInput userName;
	  public UIInput password;
	  public GameObject progressDialog;
	  public UIPanel login_panel;
	  public UIButton submit_btn;
	  public UIButton reset_btn;
	//public GameObject uiCamera;
	static string submit_btn_label="login_submit";
	static string reset_btn_label="login_reset";
	void Start(){
		//reset progress bar and initialize of resources

		//关闭登录ＵＩ
		SceneManager.getInstance().disableUI(UI_CONSTANT.UI_LOGIN);

		NGUITools.SetActive(progressDialog,true);
	}
	void LateUpdate(){
		NGUITools.SetActive(progressDialog,false);
        if (UICamera.selectedObject != null)
        {
            if (UICamera.selectedObject.name == submit_btn_label)
            {
                if ((userName.value != null && userName.value != "") && (password.value != null && password.value != ""))
                {
                    DebugTool.Log("userName =" + userName.value + " ;" + "password =" + password.value);
                    //do login action
                    disableOnClickEvents(); //disable all components when click to login

                }
            }

            if (UICamera.selectedObject.name == reset_btn_label)
            {
                userName.value = "";
                password.value = "";
            }
        }
	}
	//disable input button and Field when click to login
	void disableOnClickEvents(){
		userName.enabled=false;
		password.enabled=false;
		submit_btn.enabled=false;
		reset_btn.enabled=false;
	}
	//enable input button and textField
	void enableOnClickEvents(){
		userName.enabled=true;
		password.enabled=true;
		submit_btn.enabled=true;
		reset_btn.enabled=true;
	}
}

}